home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wsens.pro < prev    next >
Text File  |  1997-07-08  |  3KB  |  119 lines

  1. ; $Id: wsens.pro,v 1.4 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This simple widget example demonstates the use of the
  7. ; SENSITIVE keyword to the WIDGET_CONTROL routine.
  8.  
  9. ; A widget is said to be sensitive when it can be manipulated.
  10. ; When a widget is desensitized, it is 'grayed-out' and cannot
  11. ; be manipulated.
  12.  
  13.  
  14. PRO wsens_event, event
  15. ; This is the event handler for the WSENS widget.
  16.  
  17. ; This COMMON block is used because both sens and sens_event must
  18. ; know the widget ID's of all the widgets that will be desensitized:
  19.  
  20. COMMON wsensblock, desens_list1, desens_list2, button4
  21.  
  22. ; Use WIDGET_CONTROL to get the user value of any widget touched and put
  23. ; that value into 'eventval':
  24.  
  25. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  26.  
  27. ; Perform actions based on the User Value of the button which was pressed:
  28.  
  29. CASE eventval OF
  30.     'DESENSITIZE': BEGIN
  31.             ; Desensitize those widgets in desens_list1:
  32.  
  33.             FOR i=0,(N_ELEMENTS(desens_list1) -1) DO BEGIN
  34.                  WIDGET_CONTROL, desens_list1[i], SENSITIVE=0
  35.             ENDFOR
  36.  
  37.             ; Sensitize the button which brings those buttons back:
  38.             WIDGET_CONTROL, button4, SENSITIVE=1
  39.  
  40.                END
  41.  
  42.     'ALLOW'         : BEGIN
  43.             ; Desensitize those widgets in desens_list2:
  44.  
  45.             FOR i=0,(N_ELEMENTS(desens_list2) -1) DO BEGIN
  46.                  WIDGET_CONTROL, desens_list2[i], SENSITIVE=0
  47.             ENDFOR
  48.  
  49.                         ; Sensitize the button which brings those buttons back
  50.                         WIDGET_CONTROL, button4, SENSITIVE=1
  51.  
  52.                END
  53.  
  54.        'DONE'       : WIDGET_CONTROL, event.top, /DESTROY    ;Destroy the widgets.
  55.  
  56.    'RESENSITIZE': BEGIN
  57.                      ; Re-sensitize those widgets in desens_list1:
  58.  
  59.                      FOR i=0,(N_ELEMENTS(desens_list1) -1) DO BEGIN
  60.                          WIDGET_CONTROL, desens_list1[i], SENSITIVE=1
  61.                      ENDFOR
  62.  
  63.                      ; DE-Sensitize button4
  64.                      WIDGET_CONTROL, button4, SENSITIVE=0
  65.                   END
  66.  
  67. ENDCASE
  68. END
  69.  
  70.  
  71.  
  72. PRO wsens, GROUP=GROUP
  73. ; This is a procedure that creates the widgets for the widget
  74. ; sensitize/desensitize example.
  75.  
  76. ; The COMMON block is used because both sens and sens_event must
  77. ; know the widget ID's of all widgets that will be desensitized:
  78.  
  79. COMMON wsensblock, desens_list1, desens_list2, button4
  80.  
  81. ; A top -level base widget with the title "Exclusive Buttons Example" will
  82. ; hold the exclusive buttons:
  83. base = WIDGET_BASE(TITLE = 'Sensitivity Example', $
  84.     /COLUMN, $
  85.     XSIZE=400)
  86.  
  87. button1 = WIDGET_BUTTON(base, $
  88.                 UVALUE = 'DONE', $
  89.                 VALUE = 'DONE')
  90.  
  91. button2 = WIDGET_BUTTON(base, $
  92.                 UVALUE = 'DESENSITIZE', $
  93.                 VALUE = 'Desensitize The Top Three Buttons')
  94.  
  95. button3 = WIDGET_BUTTON(base, $
  96.                 UVALUE = 'ALLOW', $
  97.                 VALUE = 'Desensitize Buttons Two and Three')
  98.  
  99. button4 = WIDGET_BUTTON(base, $
  100.                    UVALUE = 'RESENSITIZE', $
  101.         VALUE = 'Sensitize All Buttons Except This One')
  102.  
  103. ; Make button4 initially insensitive:
  104. WIDGET_CONTROL, button4, SENSITIVE=0        ;notice that the button can
  105.                         ;be desensitized before being
  106. ; Realize the widgets:                ;realized.
  107. WIDGET_CONTROL, base, /REALIZE
  108.  
  109. ; Build the arrays of items to desensitize:
  110.  
  111. desens_list1 = [button1, button2, button3]
  112. desens_list2 = [button2, button3]
  113.  
  114. ; Hand off control of the widget to the XMANAGER:
  115. XMANAGER, "wsens", base, GROUP_LEADER=GROUP, /NO_BLOCK
  116.  
  117. END
  118.  
  119.